using System;
using Volo.Abp.Domain.Entities.Auditing;

namespace BW.WMS.WareHouseManage
{
    /// <summary>
    /// 库存流水实体
    /// </summary>
    public class InventoryTransaction : FullAuditedEntity<Guid>
    {
        /// <summary>
        /// 流水号
        /// </summary>
        public string TransactionNo { get; set; }
        
        /// <summary>
        /// 物料ID
        /// </summary>
        public Guid MaterialId { get; set; }
        
        /// <summary>
        /// 仓库ID
        /// </summary>
        public Guid WarehouseId { get; set; }
        
        /// <summary>
        /// 库位ID
        /// </summary>
        public Guid LocationId { get; set; }
        
        /// <summary>
        /// 批次号
        /// </summary>
        public string BatchNo { get; set; }
        
        /// <summary>
        /// 交易类型 (1-入库，2-出库，3-移库，4-盘盈，5-盘亏，6-调整)
        /// </summary>
        public int TransactionType { get; set; }
        
        /// <summary>
        /// 交易数量
        /// </summary>
        public decimal Quantity { get; set; }
        
        /// <summary>
        /// 交易前数量
        /// </summary>
        public decimal BeforeQuantity { get; set; }
        
        /// <summary>
        /// 交易后数量
        /// </summary>
        public decimal AfterQuantity { get; set; }
        
        /// <summary>
        /// 交易时间
        /// </summary>
        public DateTime TransactionTime { get; set; }
        
        /// <summary>
        /// 关联单号（如入库单号、出库单号等）
        /// </summary>
        public string RelatedOrderNo { get; set; }
        
        /// <summary>
        /// 关联单据类型（1-入库单，2-出库单，3-移库单，4-盘点单）
        /// </summary>
        public int RelatedOrderType { get; set; }
        
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        
        // 导航属性
        public virtual Material Material { get; protected set; }
        public virtual Warehouse Warehouse { get; protected set; }
        public virtual Location Location { get; protected set; }
        
        protected InventoryTransaction()
        {
        }
        
        public InventoryTransaction(
            Guid id,
            string transactionNo,
            Guid materialId,
            Guid warehouseId,
            Guid locationId,
            int transactionType,
            decimal quantity,
            decimal beforeQuantity,
            decimal afterQuantity,
            string batchNo = null) : base(id)
        {
            TransactionNo = transactionNo;
            MaterialId = materialId;
            WarehouseId = warehouseId;
            LocationId = locationId;
            TransactionType = transactionType;
            Quantity = quantity;
            BeforeQuantity = beforeQuantity;
            AfterQuantity = afterQuantity;
            BatchNo = batchNo;
            TransactionTime = DateTime.Now;
        }
    }
} 